package com.yangchao.webflux.controller;

import com.yangchao.webflux.vo.UserVO;
import com.yangchao.webflux.webserver.UserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController

public class GetUserInfoController {


    @Autowired
    UserClient userClient;

    @GetMapping(value = "/users",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<UserVO> getUser() {
       return userClient.getAll(new UserVO(){{
           setId(0L);
           setName("user01");
       }}).log();
    }
}
